#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,d[100005],v[100005],a[100005],p[100005],pf[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T>0){
            int ans1=0,ans2=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=0;i<n;i++)    scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=0;i<m;i++)    scanf("%d",&p[i]);
        for(int i=0;i<n;i++){
            if(v[i]<=V&&a[i]<=0) continue;
            else if(v[i]>V&&a[i]>=0){
                for(int j=0;j<m;j++){
                    if(p[j]>d[i]){
                        ans1++;
                        pf[j]=1;
                        continue;
                    }
                }
            }
            else if(v[i]<=V&&a[i]>0){
                int tmp=(V-v[i])/a[i]+1;
                for(int j=0;j<m;j++){
                    if(p[i]>V+tmp){
                        ans1++;
                        pf[j]=1;
                        continue;
                    }
                }
            }
            else if(v[i]>V&&a[i]<0){
                unsigned int tmp=(v[i]-V)/a[i]-1;
                for(int j=0;j<m;j++){
                    if(p[i]<V+tmp&&p[i]>V){
                        ans1++;
                        pf[j]=1;
                        continue;
                    }
                }
            }
        }
        for(int i=0;i<m;i++){
            if(pf[i]==1)    ans2++;
        }
        printf("%d %d\n",3,3);
        T--;
    }
    return 0;
}
